home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 January - Disc 2 / Macworld (1999-01) (Disk 2).dmg / Serious Demos / Symbolic Composer 4.2 / Environment / System / SYMBOL / Symbol Generators / Grammars / defsym next >
Text File  |  1998-10-23  |  2KB  |  54 lines

  1. defsym symbol definition &optional :levels :tree
  2.  
  3. defsym defines a recursive rewriting rule, or a recursive symbol structure for a symbol. The optional :levels is valid only for the L-system defining the rewriting levels of a rule. If is missing, then the  definition is active on all levels. If there are several definition active at the same level, the L-system picks up one of them randomly when creating the output.
  4.  
  5. (initdef)
  6. (defsym a '(a b c))
  7. (defsym b '(c d e c b a))
  8.  
  9. (gen-trans a 4)
  10. --> (a b c d e f g e g h i g f e f d f g h f e g ...)
  11. (gen-notrans a 4)
  12. --> (a a a a a b c b c d e c b a c b c d e c b c ...) 
  13.  
  14. The :tree is 'tree if not given. If you want to keep multiple definitions in memory at the same time without interference problems use different trees.
  15.  
  16. (initdef 'melody1)
  17. (defsym a '(a b) :tree 'melody1)
  18. (defsym b '(a b) :tree 'melody1)
  19. (gen-trans a 3 'melody1)
  20. --> (a b c d e d d e c c d e d d e)
  21.  
  22. (initdef 'melody2)
  23. (defsym a '(b c) :tree 'melody2)
  24. (defsym c '(a c) :tree 'melody2)
  25. (gen-trans a 3 'melody2)
  26. --> (a c d c e f e d f)
  27.  
  28. Multiple Definitions
  29.  
  30. It is also possible to define two different associations for a symbol. When the output is produced the system picks randomly one of the definitions. For example,
  31.  
  32. (initdef)
  33. (defsym a '(a b))
  34. (defsym a '(b a))
  35.  
  36. (gen-notrans a 1)
  37. --> (a b a)
  38. or
  39. --> (a a b)
  40.  
  41. Rewriting Rules
  42.  
  43. The rewriting rules are suited to modelling the growth of organic systems. In the following example the definition g is active on the levels 1 3 5 and the definition x is active on the levels 2, 4, 5 and 6. When the definitions are rewritten on the level 5, the random generator chooses one of the two values.
  44.  
  45. (initdef)
  46. (defsym g '(g f x < + g > < - g >) :levels '(1 3 5))
  47. (defsym x '(x < - f f f > < + f f f > f x) :levels '(2 4 5 6))
  48. (defsym - '-)
  49. (defsym + '+)
  50. (defsym < '<)
  51. (defsym > '>)
  52.  
  53. The <, >, + and - symbols have special meaning in rewriting. See gen-rewrite, transform and filter-preserve functions. The random procedure works also with gen-trans and gen-notrans functions. Other symbol defining functions are undef, which undefines rules, and initdef, which clears all definitions.
  54.